﻿using System;
using System.Collections.Generic;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using YJKArchMethodLibrary.ColumnProfileAnalyze;
using TopologySearch;

namespace SectionSignAndFilled.StairsRoomPlanSign.ControlLayer
{
	public class ColumnCurveGeter
	{
		private ColumnCurveGeter(ExternalCommandData cmdData)
		{
			this.m_useAnalyzer = new ColumnProfileAnalyzer(cmdData);
			this.m_doc = cmdData.Application.ActiveUIDocument.Document;
		}

		public static ColumnCurveGeter GetCurveGeter(ExternalCommandData cmdData)
		{
			if (ColumnCurveGeter.m_singleTag == null)
			{
				ColumnCurveGeter.m_singleTag = new ColumnCurveGeter(cmdData);
			}
			return ColumnCurveGeter.m_singleTag;
		}

		public List<Curve> GetColumnCurves(FamilyInstance inputColumn, double useZ, Transform inputTransform = null)
		{
			Document document = inputColumn.Document;
			List<ColumnProfileInfo> list = new List<ColumnProfileInfo>();
			List<Pole2D> list2 = new List<Pole2D>();
			list2 = this.m_useAnalyzer.GetColumnProfile(inputColumn, ref list);
			List<Curve> list3 = new List<Curve>();
			foreach (Pole2D pole2D in list2)
			{
				list3.Add(pole2D.ToCurve(document, true));
			}
			list3 = Utility.GetListTransformCurve(list3, inputTransform);
			list3 = Utility.ChangeLstCurveZ(list3, useZ);
			return list3;
		}

		private static ColumnCurveGeter m_singleTag;

		private ColumnProfileAnalyzer m_useAnalyzer;

		private Document m_doc;
	}
}
